package com.wly.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JdbcDemo1 {
    public static void main(String[] args) throws Exception {
//        导入驱动jar包
//        注册驱动
        Class.forName("com.mysql.jdbc.Driver");
//        获取数据库连接对象
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test",
                                    "root",
                                    "root");
//        定义sql语句
        String sql = "update student set address = '水帘洞' where id = 1";
//        获取执行sql的对象Statement
        Statement stmt = conn.createStatement();
//        执行sql
        int count = stmt.executeUpdate(sql);
//        处理结果
        System.out.println(count);
//        释放资源
        stmt.close();
        conn.close();
    }
}
